package category;


/**
 * 总钱数为整数 total。一支钢笔为 cost1 和一支铅笔为 cost2, 计算花费部分或者全部的钱，去买任意数目的两种笔不同方案数目 。
 * 时间：O(total/cost1) 空间：O(1)
 */
public class CountPurchasingSchemes {
    public static void main(String[] args) {
        CountPurchasingSchemes countPurchasingSchemes = new CountPurchasingSchemes();
        int i = countPurchasingSchemes.countPurchasingSchemes(3, 1, 2);
        System.out.println(i);
        int i1 = countPurchasingSchemes.countPurchasingSchemes(5, 1, 2);
        System.out.println(i1);
    }
    public int countPurchasingSchemes(int total, int cost1, int cost2) {
        int count = 0;
        for (int i = 0; i <= total / cost1; i++) {
            int balance = total - i * cost1;
            count += balance / cost2 + 1;
        }
        return count;
    }
}
